#!/bin/bash

#sleepTime=0.1
toggle_pins()
{
    for((i=0;i<${#gpio_group[*]};i++))
    do
#            echo ${gpio_group[i]}
            ./gpio set ${gpio_group[i]}
#            sleep $sleepTime
    done

    for((i=0;i<${#gpio_group[*]};i++))
    do
            ./gpio clear ${gpio_group[i]}
#            sleep $sleepTime
    done
}


./gpio clear 418
sleep 0.1
./gpio set 418
sleep 2

#./gpio input 469
gpio_group=(502 471 470 473 472 475 474 477 476 386 478 384 468 385 500 387 453 455 454 457 456 459 458 463 460 462 464 451 461 450 452 449 448 509 511 507 510 505 508 503 506 501 504)

toggle_pins
sleep 0.2
p8_status=$(./gpio input 469)
[ $p8_status -ne 1 ] && { echo "Header P8 test fail"; exit 1; }
./gpio clear 490
echo "Header P8 test PASS"
exit 0
